home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: howland.reston.ans.net!torn!nott!emr1!jagrant
- From: jagrant@emr1.emr.ca (John Grant)
- Subject: why not add getch() to the std C RTL?
- Message-ID: <DM85L8.5Jn@emr1.emr.ca>
- Organization: Energy, Mines, and Resources, Ottawa
- Date: Sun, 4 Feb 1996 00:05:32 GMT
-
- There are *many* people who want to do the following in their C programs:
- - read a single unbuffered keystroke (getch() in DOS, ioctl in unix...)
- - read a directory (findfirst/findnext in DOS, readdir in unix...)
- - ...
-
- The usual response is "not standard C, o/s-specific" etc.
-
- Ok, so why would the ANSI committee not consider implementing these things
- into standard C? Yes, I know their *implementation* is O/S-specific, but
- that doesn't mean the function can't be part of the RTL, can it? It is
- up to each vendor to implement those functions as required for their O/S.
- The details are irrelevant to the programmer, as long as the function exists
- and does as advertised. I'm sure the ANSI folks have considered it, but
- why was it rejected?
-
- The filename wildcards are O/S-specific and do not have to be part of a
- standard set of functions to read filenames. The directory reading stuff
- should just open the dir, read all entries & close it. That would be the
- standard part. After that, each programmer or vendor could write a layer
- over top of that which filters the filenames using the local wildcards.
- That would be the non-standard part.
-
- This can't be any more O/S-specific than implementations of malloc. Management
- of memory is a *very* O/S-specific thing and is implemented differently on
- every different O/S. If they can make malloc() a standard, why can't they
- make some sort of getch() a standard too?
-
- I can't believe that there are *reasonably modern* O/S out there that do not
- allow a single keystroke of input or that do not have any way of obtaining a
- list of filenames. DOS can do it & unix can do it. I have done this on
- Data General AOS/VS & VAX/VMS. Or is there a UNIVAC out there that can't
- do it, so the ANSI committee won't consider it? Let me guess, it's the
- IBM synchronous terminal I/O that's keeping us in the Dark Ages, right?
-
- I've seen many suggestions here to obtain the curses package in order to
- get a function to read a single keystroke. That seems a bit silly.
- I really don't think there's much place in this modern GUI world (any O/S)
- for all of that 20-year old curses stuff, but the single keystroke function
- is extremly useful. Besides, whether or not curses is available on
- 20 different systems doesn't change the fact that it is still not part of
- the language.
-
- If languages can define specific syntax for things like fixed-length records,
- variable-length records etc (as in FORTRAN), then why can't a language (any
- language) also define a specific syntax or standard function to read a
- single keystroke. It's just a different type of 'record'.
-
- Has the ANSI committee for C decided to 'freeze' the language and not develop
- the standard RTL any further?
- --
- John A. Grant jagrant@emr1.emr.ca
- Airborne Geophysics
- Geological Survey of Canada, Ottawa
-